package com.foreknow.elm.service.Impl;

import com.foreknow.elm.dao.BusinessDao;
import com.foreknow.elm.dao.Impl.BusinessDaoImpl;
import com.foreknow.elm.po.Business;
import com.foreknow.elm.service.BusinessService;
import com.foreknow.elm.util.DBUtil;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class BusinessServiceImpl implements BusinessService {
    @Override
    public List<Business> listBusinessByOrderTypeId(Integer orderTypeId){
        List<Business>list=new ArrayList<>();
        BusinessDao businessDao=new BusinessDaoImpl();
        try {
            list=businessDao.listBusinessByOrderTypeId(orderTypeId);
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            DBUtil.close();
        }
        return list;
    }

    @Override
    public Business getBusinessById(Integer businessId) {
        Business business=new Business();
        BusinessDao businessDao=new BusinessDaoImpl();
        try {
            business=businessDao.getBusinessById(businessId);
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            DBUtil.close();
        }
        return business;
    }

    public static void main(String[] args) {
//        BusinessService businessService=new BusinessServiceImpl();
//        Business business= businessService.getBusinessById(10003);
//        System.out.println(business.getBusinessName());

    }
}
